package com.mccken.springframework.factory.support;

import com.mccken.springframework.BeansException;
import com.mccken.springframework.factory.config.BeanDefinition;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2022-11-19 23:03
 **/
public abstract class AbstractAutowiredCapableBeanFactory extends AbstractBeanFactory {

	@Override
	protected Object createBean(String name, BeanDefinition beanDefinition) throws BeansException {
		Object bean = null;
		try {
			bean = beanDefinition.getBeanClass().newInstance();
		} catch(InstantiationException | IllegalAccessException e) {
			throw new BeansException("Instantiation of bean failed", e);
		}
		
		registerSingleton(name, bean);
		return bean;
	}
}
